//app.js
var qcloud = require('./vendor/wafer2-client-sdk/index')
var config = require('./config')
var zm = require('./utils/zm_tools.js')

App({
  onLaunch: function () {
 var that = this;
    // 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope
    wx.getUserInfo(function(x){
console.log("app",x);
    });

    wx.getSetting({
      success(res) {
        console.log("getsetting", res.authSetting);
        if (!res.authSetting['scope.userInfo']) {
          wx.authorize({
            scope: 'scope.userInfo',
            success() {
              // 用户已经同意小程序使用录音功能，后续调用 wx.startRecord 接口不会弹窗询问
              wx.getUserInfo()
            }
          })
        }
        if (!res.authSetting['scope.userLocation']) {
          wx.authorize({
            scope: 'scope.userLocation',
            success() {
              // 用户已经同意小程序使用录音功能，后续调用 wx.startRecord 接口不会弹窗询问
              //wx.getUserInfo()
            }
          })
        }
      }
    })
    //设置登陆地址
    qcloud.setLoginUrl(config.service.loginUrl)
    if (!that.globalData.userInfo) {
      zm.get("/user?app=x", {uuid:""}, function (r) {
        that.globalData.userInfo=r;
      })
    }
    //加载类型
    zm.post("/getziyuan/leixing", {}, function (r) {
      that.globalData.renwuleixing = r.jg;
    });
    
  },
  globalData: {
    userInfo: null,
    renwuleixing:[]
  }
})